#include <bits/stdc++.h>
using namespace std;

bool Check(const vector<int>& a, int k, int mex) {
  for (int i = 0; i < a.size() && k;) {
    vector<bool> used(mex, false);

    int j = i, rest;
    for (rest = mex; j < a.size() && rest > 0; j++) {
      if (a[j] < mex && !used[a[j]]) {
        rest--;
        used[a[j]] = true;
      }
    }
    if (rest > 0) {
      return false;
    }
    i = j;
    k--;
  }
  return k == 0;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;

  for (cin >> T; T; T--) {
    int n, k;

    cin >> n >> k;
    vector<int> a(n);

    for (int& x : a) {
      cin >> x;
    }

    int ll = 0, rr = n / k;
    while (ll < rr) {
      int mm = (ll + rr) >> 1;

      if (Check(a, k, mm + 1)) {
        ll = mm + 1;
      } else {
        rr = mm;
      }
    }
    cout << ll << '\n';
  }
  return 0;
}